package JavaSE;

import java.util.ArrayList;

public class 运算符练习之使用ArrayList同时返回多个值 {
    public static void main(String[] args){
        int a = 10;
        int b = 5;

        ArrayList<Integer> results = performOperations(a,b);
        System.out.println("和:"+results.get(0));
        System.out.println("差:"+results.get(1));
        System.out.println("积:"+results.get(2));
        System.out.println("商:"+results.get(3));
        System.out.println("余数:"+results.get(4));
    }

    public static ArrayList<Integer> performOperations(int x,int y) {
        ArrayList<Integer> result = new ArrayList<>();
        result.add(x+y);
        result.add(x-y);
        result.add(x*y);
        result.add(y!=0?x/y:0);
        result.add(y!=0?x%y:0);

        return result;
    }
}
